package lesson01;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Class_001_InetAddress {

    public static void main(String[] args){
        InetAddress localhost = null;
        try {
            localhost = InetAddress.getByName("127.0.0.1");
            System.out.println(localhost);

            System.out.println("==================================");
            System.out.println(InetAddress.getByName("localhost"));
            System.out.println(InetAddress.getLocalHost());

            System.out.println("==================================");

            InetAddress baidu = InetAddress.getByName("www.baidu.com");
            System.out.println(baidu);
            System.out.println(baidu.getHostName());
            System.out.println(baidu.getHostAddress());
            System.out.println(baidu.getAddress());
            System.out.println(baidu.getCanonicalHostName());
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
